home *** CD-ROM | disk | FTP | other *** search
- ;Double Buffering
- ;----------------
- ;This just shows how to double buffer the screen. You can also try out
- ;triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
- ;ScreenStruct.
- ;
- ;Notice that this thing does in fact fully multi-task (no forbid/permit)!
- ;Instead we set our task priority to be a little higher than any other tasks
- ;-- if we didn't do this sometimes our frames could be stalled (try removing
- ;the SetUserPri and watch the demo again).
-
- opt o+
-
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- LOCAL = 0
-
- SECTION "Double_Buffer",CODE
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- Start: MOVEM.L A0-A6/D1-D7,-(SP)
- move.l ($4).w,a6
- lea GMS_Name(pc),a1
- moveq #$00,d0
- CALL OpenLibrary
- move.l d0,GMS_Base
- beq.s Quit
-
- move.l GMS_Base(pc),a6 ;Set the task priority to a
- CALL SetUserPri ;user-selected level.
-
- lea ScreenStruct(pc),a0 ;Add screen for use.
- CALL Add_Screen
- tst.l d0
- bne.s Error
-
- move.l SS_MemPtr1(a0),a1 ;Destination = SS_MemPtr1.
- lea PackedPicFile(pc),a0 ;File Name.
- CALL QuickLoad
- tst.l d0
- beq.s Error
-
- lea ScreenStruct(pc),a0 ;Unpack the data on top of itself.
- move.l SS_MemPtr1(a0),a1
- move.l a1,a0
- moveq #$00,d0
- CALL SmartUnpack
-
- lea ScreenStruct(pc),a0 ;Now show the screen/pic.
- CALL Show_Screen
-
- ;===========================================================================;
- ; MAIN LOOP
- ;===========================================================================;
-
- Loop: CALL Wait_OSVBL ;Nice VBL wait for multi-tasking.
- CALL SwapBuffers
- moveq #JPORT1,d0 ;Port 1 (mouse)
- moveq #JT_SWITCH,d1
- CALL Read_JoyPort
- btst #JS_FIRE1,d0
- beq.s Loop
-
- ;===========================================================================;
- ; RETURN TO DOS
- ;===========================================================================;
-
- CALL Delete_Screen ;Give back screen memory etc.
-
- Error move.l GMS_Base(pc),a1
- move.l ($4).w,a6
- CALL CloseLibrary
- Quit MOVEM.L (SP)+,A0-A6/D1-D7
- moveq #$00,d0
- rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- AMT_PLANES = 5
-
- ScreenStruct:
- dc.l "GSV1"
- dc.l 0,0,0 ;Screen_Mem1/2/3
- dc.l 0 ;Screen link.
- dc.l ScreenPalette ;Address of screen palette
- dc.l 0 ;Address of rasterlist.
- dc.l 0 ;Amt of colours in palette.
- dc.w 256,320,320/8 ;Screen Height, Width, Width/8
- dc.w 256,320,320/8 ;Pic Height, Width, Width/8
- dc.w AMT_PLANES ;Amt_Planes
- dc.w 0,0 ;Hardware offset, X/Y
- dc.w 0 ;Scroll buffer in pixels/8.
- dc.w 0,0 ;X/Y counters (for scrolling).
- dc.l DBLBUFFER|NOBURST ;Special attributes.
- dc.w LORES ;Screen mode.
- dc.b INTERLEAVED ;Screen type
- dc.b 0 ;Screen Is Being Displayed?
- dc.l 0,0 ;Reserved area.
- even
-
- ScreenPalette:
- dc.w $0000,$0A77,$0B88,$0866,$0A98,$0877,$0B99,$0CBB
- dc.w $0ABB,$0CCC,$0333,$0554,$0556,$0665,$0788,$0222
- dc.w $0466,$0345,$0677,$0888,$0234,$0322,$0844,$0733
- dc.w $0632,$0955,$09AA,$0022,$0832,$0943,$0DCC,$0DDD
-
- PackedPicFile:
- IFNE LOCAL
- dc.b "GAMESLIB:"
- ENDC
- dc.b "data/Pic320.pak",0
- even
-